<?php
$labels = array(
	'name' => _x('Review', 'post type general name', 'your_text_domain'),
	'singular_name' => _x('Review', 'post type singular name', 'your_text_domain'),
	'add_new' => _x('Add New', 'Review', 'your_text_domain'),
	'add_new_item' => __('Add New Review', 'your_text_domain'),
	'edit_item' => __('Edit Review', 'your_text_domain'),
	'new_item' => __('New Review', 'your_text_domain'),
	'all_items' => __('All Review', 'your_text_domain'),
	'view_item' => __('View Review', 'your_text_domain'),
	'search_items' => __('Search Review', 'your_text_domain'),
	'not_found' =>  __('No Review found', 'your_text_domain'),
	'not_found_in_trash' => __('No Review found in Trash', 'your_text_domain'), 
	'parent_item_colon' => '',
	'menu_name' => __('Product Review', 'your_text_domain')
);
$args = array(
	'labels' => $labels,
	'public' => true,
	'publicly_queryable' => true,
	'show_ui' => true, 
	'show_in_menu' => true, 
	'query_var' => true,
	'rewrite' => array( 'slug' => _x( 'product-review', 'URL slug', 'your_text_domain' ) ),
	'capability_type' => 'post',
	'has_archive' => true, 
	'hierarchical' => false,
	'menu_position' => null,
	'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt','page-attributes' )
); 
register_post_type('productreview', $args);
function cc_get_product_review($productid){
	global $wpdb;
	$arr_post = array();
	$query = "SELECT * FROM  wp_postmeta WHERE meta_key = '_review_select_post' AND meta_value = $productid";
	$product_review = $wpdb->get_results($query);
	foreach($product_review as $key=>$val){
		$arr_post[] = $val->post_id;
	}
	return $arr_post;
}
function cc_print_review_product($productid){
	$arr_review = cc_get_product_review($productid);
	$args = array(
		'post_type' => 'productreview',
		'meta_query' => array(
			array(
				'key' => '_review_select_post',
				'value' => $productid,
			)
		)
	 );
	$postslist = get_posts( $args );
	if ($postslist) {
		require('view/review-product.html');
	}
}
function cc_get_product_video($postid,$width,$height){
	global $video_meta;
	$meta = get_post_meta($postid, $video_meta->get_the_id(), TRUE);
	cc_print_youtube( sd_get_youtube_id($meta['product_video']),$width,$height );
}
?>